#ifndef LIB_UTILS_UI_OAUTHVERIFYDIALOG_H
#define LIB_UTILS_UI_OAUTHVERIFYDIALOG_H

#include "../utils_global.h"
#include <QTextBrowser>
#include <QPushButton>
#include <QVBoxLayout>
#include <QDialog>

namespace TWUtils {
	class OAuthClient;
namespace UI {

	class TWUTILS_EXPORT OAuthVerifyDialog : public QDialog
	{
		Q_OBJECT
		public:
			class InitObject
			{
				public:
					InitObject():needVerifier(false),requestTokenParams(0),accessTokenParams(0){}
					~InitObject(){}

					bool needVerifier;
					OAuthClient* client;
					QMap<QByteArray,QByteArray>* requestTokenParams;
					QMap<QByteArray,QByteArray>* accessTokenParams;

					QString requestTokenURL;
					QString accessTokenURL;
					QString displayInfo;
			};

			OAuthVerifyDialog(InitObject&);
			~OAuthVerifyDialog();
			bool setup();
		private:
			enum State
			{
				NoRequestToken,
				HasRequestToken,
				NoAccessToken
			};
			State			e_state;
			QTextBrowser		m_msgBrowser;
			QPushButton		m_okBtn;
			QVBoxLayout		m_layout;

			InitObject& initData;
		private slots:
			void openUrl(const QUrl&);
			void requestTokenAcquired(bool);
			void accessTokenAcquired(bool);
			void okBtnClicked();
	};
}
} // namespace TWUtils

#endif // LIB_UTILS_OAUTHVERIFYDIALOG_H
